package org.shareworth.online_life.client;

import org.shareworth.online_life.client.mvc.AppController;
import org.shareworth.online_life.client.mvc.AppEvents;
import org.shareworth.online_life.client.mvc.goal.GoalController;

import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.state.CookieProvider;
import com.extjs.gxt.ui.client.state.StateManager;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class Online_life implements EntryPoint {

	@Override
	public void onModuleLoad() {

		// RootPanel.get().add(new MainLayout());
		Dispatcher dispatcher = Dispatcher.get();
		dispatcher.addController(new AppController());
		dispatcher.addController(new GoalController());
		StateManager.get().setProvider(
				new CookieProvider(null, null, null, true));
		Object object = StateManager.get().get("login");
		if (object == null || !(Boolean) object) {
			dispatcher.dispatch(AppEvents.LOGIN);
		} else {
			dispatcher.dispatch(AppEvents.INIT);
		}
		// Window window = new Window();
		// window.setSize(100, 100);
		// window.setHeading("测试窗口");
		// RootPanel.get().add(window);
		// 清空页面原有的HTML代码
//		Viewport viewport = new Viewport();
//		RootPanel.get().add(viewport);
		// myDesktop.addWindow(new Window());
	}

	// private Desktop desktop = new Desktop();
	//
	// public void onModuleLoad() {
	//
	// TaskBar taskBar = desktop.getTaskBar();
	//
	// StartMenu menu = taskBar.getStartMenu();
	// menu.setHeading("Guest User");
	//
	// MenuItem menuItem = new MenuItem("Window");
	//
	// menu.add(menuItem);
	//
	// menuItem = new MenuItem("'Modal' Messagebox");
	//
	// menu.add(menuItem);
	// }
}
